package name.fowler.refactoring.simplestore;

import java.util.ArrayList;
import java.util.List;

public class Customer {
	private String m_Name;
	private List<Rental> movieRentals = new ArrayList<Rental>();

	public Customer(String name) {
		m_Name = name;
	}

	public String getName() {
		return m_Name;
	}


	public void addRental(Rental arg){
		movieRentals.add(arg);
	}

	public Statement getStatement(FrequencyCalculator calculator)
	{
		double totalAmount = 0;
		
				
		String result = "Rental record for " + m_Name + "\n";
		
		for(Rental rental: movieRentals) {
			double thisAmount = 0;
			
			thisAmount += rental.getAmount();

			result += "\t" + rental.getMovie().getTitle() + "\t" + thisAmount + "\n";
			totalAmount += thisAmount;
		}

		result += "Amount owed is " + totalAmount + "\n";
		int points = calculator.getFrequencyPoint(movieRentals);
		result += "You earned " + points + " frequent renter points.";
		
		return new Statement(result, totalAmount, points);
	}
	
}

